package effects.chroma
{
	import flash.display.MovieClip;
	import flash.display.BitmapData;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;
	import flash.geom.Point;
	import flash.geom.ColorTransform;
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.BlendMode;
	import flash.filters.BlurFilter;
	import flash.display.DisplayObject;
	import evo.engine.AbstractPostProcessor;
	
	public class ChromaBlurEffect extends AbstractPostProcessor
	{	
		private var clipMatrix:Matrix;
		public var offsetScale:Number = 5;
	//	public var focusPoint:Point;
		private var blurColor1:ColorTransform;
		private var blurColor2:ColorTransform;
		private var blurColor3:ColorTransform;
		private var blurFilter:BlurFilter;
		public var mode:String;
		private	var mat:Matrix = new Matrix();

		public override function init(params:Object=null):void
		{			
			super.init(params);
						
			if(params.offsetScale)offsetScale=params.offsetScale;
			if(params.blurColor1)blurColor1 = params.blurColor1;
				else blurColor1= new ColorTransform(.75,.25,0,1,0,0,0,0); // White blur
			if(params.blurColor2)blurColor2 = params.blurColor2;
				else blurColor2= new ColorTransform(.25,0.50,.25,1,0,0,0,0); // White blur
			if(params.blurColor3)blurColor3 = params.blurColor3;
				else blurColor3= new ColorTransform(0,.25,.75,1,0,0,0,0); // White blur
			if(params.mode)mode = params.mode;
				else mode = "add";
 		}
 		
		public override function set output(buffer:BitmapData):void
		{
			super.output = buffer;
			defaultInput();
		} 		
		
		public override function play(dt:Number):void
		{
				_input.lock();
				_input.fillRect(_input.rect,0);

				super.play(dt);
				_input.unlock();
			
				mat.identity();
				mat.tx = -offsetScale*0.7;
				buffer.draw(input,mat,blurColor1,mode);
				mat.tx = 0;
				mat.ty = +offsetScale;			
				buffer.draw(input,mat,blurColor2,mode);
				mat.tx = +offsetScale*0.7;
				mat.ty = 0;
				buffer.draw(input,mat,blurColor3,mode);
		};
	}
}